package demo3;
class Animal{
    protected String name;

    public Animal(String name) {
        this.name = name;
    }
}
class Dog extends Animal{

    public Dog(String name) {
        super(name);
    }
}
interface IFlying{
    void fly();
}
interface IRunning{
    void run();
}
interface Iswimming{
    void swimming();
}
class Bird extends Animal implements IFlying{
    public Bird(String name) {
        super(name);
    }
    @Override
    public void fly() {
        System.out.println(this.name+"正在飞!");
    }
}
class Frog extends Animal implements IRunning,Iswimming{
    public Frog(String name) {
        super(name);
    }
    @Override
    public void run() {
        System.out.println(this.name+"正在跑");
    }
    @Override
    public void swimming() {
        System.out.println(this.name+"正在游泳");
    }
}
class Duck extends Animal implements IRunning,IFlying,Iswimming{

    public Duck(String name) {
        super(name);
    }

    @Override
    public void run() {
        System.out.println(this.name+"正在跑");
    }
    @Override
    public void fly() {
        System.out.println(this.name+"正在飞!");
    }
    @Override
    public void swimming() {
        System.out.println(this.name+"正在游泳");
    }
}
public class test4 {
    public static void runFunc(IRunning iRunning) {
        iRunning.run();
    }
    public static void main(String[] args) {
        runFunc(new Duck("鸭子"));
        runFunc(new Duck("青蛙"));
    }
}
























